<template>
  <div class="shop">
    <el-button class="setting_converse"
      type="primary"
      @click="converseSettingInfo">保存</el-button>
    <div class="setting_top">
      <p class="setting_title">门店订单退款设置</p>
      <div class="valite_setting">
        <el-row>
          <el-col class="col_setting"
            :span="24">
            <p>到店核销自提订单有效期是指在此期间核销有效，超过核销有效期，订单自动退还至用户付款渠道；（爆款订单、会员专享、拼团订单）</p>
          </el-col>

          <div class="col_setting">
            <span>有效期:</span>
            <el-input style="width:200px;"
              type="text"
              v-model="refund_valid_term">
              <p class="note_back"
                slot="suffix">天</p>
            </el-input>
            <span class="note_span">有效期是大于7的数值，比如填写7天就是，订单7天没有提货即原路退款</span>
          </div>
        </el-row>
      </div>
    </div>

    <div class="setting_top">
      <p class="setting_title">交易费率设置</p>
      <div class="valite_setting">
        <el-row>
          <el-col class="col_setting"
            :span="24">
            <p>系统设置商家结算时扣除的交易费率（订单显示用户实付金额，结算金额为扣除交易费率后的金额）</p>
          </el-col>

          <div class="col_setting">
            <span>费率:</span>
            <el-input style="width:200px;"
              type="text"
              v-model="transaction_rate">
              <!-- <p class="note_back"
                slot="suffix">%</p> -->
            </el-input>
            <span class="note_span">不填或者填0时不扣减商家费率，不能大于1</span>
          </div>
        </el-row>
      </div>
    </div>

    <div class="setting_mid">
      <p class="setting_title">小店权限设置</p>
    </div>
    <div class="setting_bottom">
      <div class="valite_setting">
        <div class="col_setting">
          <span>小店爆品设置:</span>
          <el-input style="width:200px;"
            type="text"
            v-model="form.explosive_limit">
            <p class="note_back"
              slot="suffix">个</p>
          </el-input>
          <span class="note_span">限制小店可以上传的爆品数量</span>
        </div>
        <div class="col_setting">
          <span>小店活动数限制:</span>
          <el-input style="width:200px;"
            type="text"
            v-model="form.activity_limit">
            <p class="note_back"
              slot="suffix">个</p>
          </el-input>
          <span class="note_span">限制小店可以上传的活动数量</span>
        </div>
        <div class="col_setting">
          <span>小店基础商品库限制:</span>
          <el-input style="width:200px;"
            type="text"
            v-model="form.product_limit">
            <p class="note_back"
              slot="suffix">个</p>
          </el-input>
          <span class="note_span">限制小店可以上传的基础商品库数量</span>
        </div>
        <div class="col_setting">
          <span>会员专享商品数限制:</span>
          <el-input style="width:200px;"
            type="text"
            v-model="form.vip_limit">
            <p class="note_back"
              slot="suffix">个</p>
          </el-input>
          <span class="note_span">限制小店可以上传会员专享商品数量</span>
        </div>
        <div class="col_setting">
          <span>现金券数量限制:</span>
          <el-input style="width:200px;"
            type="text"
            v-model="form.coupon_limit">
            <p class="note_back"
              slot="suffix">个</p>
          </el-input>
          <span class="note_span">限制小店可以上传现金券数量</span>
        </div>
        <div class="col_setting">
          <span>满减优惠券限制:</span>
          <el-input style="width:200px;"
            type="text"
            v-model="form.preferential_coupon_limit">
            <p class="note_back"
              slot="suffix">个</p>
          </el-input>
          <span class="note_span">限制小店可以上传优惠买单券数量</span>
        </div>
         <div class="col_setting">
          <span>会员次卡上架数限制:</span>
          <el-input style="width:160px; margin-right:20px;"
            type="text"
            v-model="form.preferential_coupon_limit">
            <p class="note_back"
              slot="suffix">个</p>
          </el-input>
          <span>单品服务次数上限:</span>
          <el-input style="width:160px; margin-right:20px;"
            type="text"
            v-model="form.preferential_coupon_limit">
            <p class="note_back"
              slot="suffix">次</p>
          </el-input>
          <span>绑定商品数上限:</span>
          <el-input style="width:160px;"
            type="text"
            v-model="form.preferential_coupon_limit">
            <p class="note_back"
              slot="suffix">个</p>
          </el-input>
        </div>
      </div>
    </div>

    <div class="setting_member">
      <!-- <p class="setting_title">会员购物返利设置</p> -->
      <p class="setting_title">红包兑换返利设置</p>
    </div>
    <div class="valite_setting">
      <div class="col_setting">
        <span>会员返利比例:</span>
        <el-input style="width:200px;"
          type="text"
          v-model="rebate_rate">
          <p class="note_back"
            slot="suffix">%</p>
        </el-input>
        <!-- <span class="note_span">爆品订单、优惠买单、现金券、拼团订单、会员专享商品订单同步生效</span> -->
         <span class="note_span">红包兑换商城的购物返利比,按利润*比例换算成返红包数,仅针对会员身份用户返红包</span>
      </div>
    </div>

    <div class="setting_member">
      <p class="setting_title">提现设置</p>
    </div>
    <div class="valite_setting">
      <div class="col_setting">
        <span>提现最小值:</span>
        <el-input style="width:200px;"
          type="text"
          v-model="withdraw_limit">
          <p class="note_back"
            slot="suffix">元</p>
        </el-input>
        <span class="note_span">设置提现最小值同步生效</span>
      </div>

      <div class="col_setting">
        <span>提现描述:</span>
        <el-input type="textarea"
          style="width:450px;"
          v-model="withdraw_description">
          <!-- <p class="note_back" slot="suffix">个</p> -->
        </el-input>

        <span class="note_span">设置提现描述</span>
      </div>
    </div>
   
     <div class="setting_member">
      <p class="setting_title">自营订单付款失效时间设置</p>
    </div>
    <div class="valite_setting">
      <div class="col_setting">
        <span>订单失效时长:</span>
        <el-input style="width:200px;"
          type="number"
          v-model="own_order_invalid_time">
          <p class="note_back"
            slot="suffix">分钟</p>
        </el-input>
        <span class="note_span">针对待付款订单的失效时长设置，仅支持输入整数，输入0表示订单不失效</span>
      </div>
    </div>

    <div class="setting_member">
      <p class="setting_title">会员完善信息返红包设置</p>
    </div>
    <div class="valite_setting">
      <div class="col_setting">
        <span>返红包金额:</span>
        <el-input style="width:200px;"
          type="text"
          v-model="first_vip_improve_rebate">
          <p class="note_back"
            slot="suffix">元</p>
        </el-input>
        <span class="note_span">仅针对会员完善信息后返红包的数额设置</span>
      </div>
    </div>
    
    <!--入驻及退费相关设置-->
     <!-- <div class="setting_mid">
     <p class="setting_title">入驻及退费相关设置</p>
     <el-button style="float:right;" size="mini" type="primary" @click="converseDepositConfig">保存</el-button>
   </div>
       <div class="valite_setting">
      <div class="col_setting">
        <span style="margin-right:12px;">是否展示押金入驻:</span>
         <el-switch
           v-model="is_show_deposit_join_shop"
           active-text="是"
           inactive-text="否"
           active-value="1"
           inactive-value="0">
         </el-switch>
        <br/>
        <br/>
        <span>小店押金入驻费:</span>
        <el-input style="width:200px;"
          type="text"
          :disabled="is_show_deposit_join_shop == 0"
          v-model="depositform.price">
          <p class="note_back"
            slot="suffix">元</p>
        </el-input>

        <span style="margin-left:24px;margin-right:12px;">会员费分成设置:</span>
        <el-input v-model="depositform.commission_rate_hui" style="width:120px;" :disabled="is_show_deposit_join_shop == 0"></el-input>
        <span style="margin:0 8px;">比</span>
        <el-input v-model="depositform.commission_rate_ptai" style="width:120px;" :disabled="is_show_deposit_join_shop == 0"></el-input>
        <span class="note_span">商家：平台设置，其中平台部分需要再做分配</span>
        <br/>
        <br/>

        <span>押金入驻小店最低会员费设置:</span>
        <el-input style="width:360px;" type="text" v-model="depositform.user_vip_price_min" :disabled="is_show_deposit_join_shop == 0">
          <p class="note_back"
            slot="suffix">元</p>
        </el-input>

         <span style="margin-left:12px;">押金入驻小店最低可分配会员费设置:</span>
        <el-input style="width:360px;" type="text" v-model="depositform.user_vip_commission_min" :disabled="is_show_deposit_join_shop == 0">
          <p class="note_back"
            slot="suffix">元</p>
        </el-input>
        <br/>
        <br/>

        <span >合伙人直邀押金店分配比例:</span>
        <el-input style="width:360px;" type="text" v-model="depositform.partner_reward_rate" :disabled="is_show_deposit_join_shop == 0">
          <p class="note_back"
            slot="suffix">%</p>
        </el-input>

        <span style="margin-left:12px;">合伙人间接邀请押金店分配比例:</span>
        <el-input style="width:360px;" type="text" v-model="depositform.partner_indirect_reward_rate" :disabled="is_show_deposit_join_shop == 0">
          <p class="note_back"
            slot="suffix">%</p>
        </el-input>
        <br/>
        <br/>
        
        <span >服务商押金店分配比例:</span>
        <el-input style="width:360px;" type="text" v-model="depositform.service_provider_reward_rate" :disabled="is_show_deposit_join_shop == 0">
          <p class="note_back"
            slot="suffix">%</p>
        </el-input>
        <span class="note_span">是指按会员费结算后的剩余可分配金额作为基数来计算的分配比例</span>

      </div>
    </div> -->
    <!--分佣返利设置-->
   <div class="setting_mid">
     <p class="setting_title">自营分佣返利设置</p>
     <el-button style="float:right;" size="mini" type="primary" @click="converseServiceCommissionRate">保存</el-button>
   </div>
    <div class="valite_setting">
      <div class="col_setting">
        <span>幕后街分佣比例:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="rateForm.shop">
          <p class="note_back"
            slot="suffix">%</p>
        </el-input>
        <!-- <span style="margin-left:12px;">服务商分佣比例:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="rateForm.sp">
          <p class="note_back"
            slot="suffix">%</p>
        </el-input> -->
        <span style="margin-left:12px;">合伙人分佣比例:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="rateForm.partner">
          <p class="note_back"
            slot="suffix">%</p>
        </el-input>
       <!-- <br/>
       <br/>
        <span class="rate_span">包括淘客订单、自营订单和其他CPS类在内的所有线上订单分佣比例设置，有从属多级关系的，按默认设置分佣，无上级的情况累计相加计算佣金比例</span>
        <br/> -->
        <!-- <span >服务商服务费:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="rateForm.sp_service_price">
          <p class="note_back"
            slot="suffix">元</p>
        </el-input> -->

        <!-- <span style='margin-left:12px;'>小店入驻费:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="ruzhuForm.shop_service_price">
          <p class="note_back"
            slot="suffix">元</p>
        </el-input> -->
      </div>
    </div>

    <div class="setting_mid">
     <p class="setting_title">优惠购分佣返利设置</p>
     <el-button style="float:right;" size="mini" type="primary" @click="converseTkServiceCommissionRate">保存</el-button>
   </div>
    <div class="valite_setting">
      <div class="col_setting">
        <span>幕后街分佣比例:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="rateForm.tk_shop">
          <p class="note_back"
            slot="suffix">%</p>
        </el-input>
        <!-- <span style="margin-left:12px;">服务商分佣比例:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="rateForm.sp">
          <p class="note_back"
            slot="suffix">%</p>
        </el-input> -->
        <span style="margin-left:12px;">合伙人分佣比例:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="rateForm.tk_partner">
          <p class="note_back"
            slot="suffix">%</p>
        </el-input>
       <!-- <br/>
       <br/>
        <span class="rate_span">包括淘客订单、自营订单和其他CPS类在内的所有线上订单分佣比例设置，有从属多级关系的，按默认设置分佣，无上级的情况累计相加计算佣金比例</span>
        <br/> -->
        <!-- <span >服务商服务费:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="rateForm.sp_service_price">
          <p class="note_back"
            slot="suffix">元</p>
        </el-input> -->

        <!-- <span style='margin-left:12px;'>小店入驻费:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="ruzhuForm.shop_service_price">
          <p class="note_back"
            slot="suffix">元</p>
        </el-input> -->
      </div>
    </div>

    <div class="setting_mid">
     <p class="setting_title"><!--服务商-->入驻费</p>
     <el-button style="float:right;" size="mini" type="primary" @click="getsetShopServicePrice">保存</el-button>
      <div class="valite_setting">
      <div class="col_setting">
        <span >小店入驻费金额:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="ruzhuForm.shop_service_price">
          <p class="note_back"
            slot="suffix">元</p>
        </el-input>
        </div>
    </div>
   </div>

    <div class="setting_mid">
     <p class="setting_title"><!--服务商-->提现代扣税设置</p>
     <el-button style="float:right;" size="mini" type="primary" @click="setWithDrawTaxDeductlimitData">保存</el-button>
      <div class="valite_setting">
      <div class="col_setting">
        <span >代扣税点:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="tax_point">
          <p class="note_back"
            slot="suffix">%</p>
        </el-input>

        <span style='margin-left:12px;'>冻结可申请抵税有效期:</span>
        <el-input style="width:160px;"
          type="number"
          min="0"
          v-model="freeze_expire_day">
          <p class="note_back"
            slot="suffix">天</p>
        </el-input>
        </div>
    </div>
   </div>
    <!--服务商相关设置-->
       <!-- <div class="setting_mid">
      <p class="setting_title">服务商相关权限设置</p>
      <el-button style="float:right;" size="mini" type="primary" @click="converseServiceIsp">保存</el-button>
    </div>
    <div class="setting_bottom">
      <div class="valite_setting">
        <div class="col_setting">
          <span>服务商奖励收益延迟到账:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="serviceForm.reward_sp_delay"
           >
            <p class="note_back"
              slot="suffix">天</p>
          </el-input>
          <span style="margin-left:12px;">邀请小店奖励延迟到账:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="serviceForm.reward_shop_delay"
           >
            <p class="note_back"
              slot="suffix">天</p>
          </el-input> -->
          <!-- <span class="note_span">是指服务商邀请服务商加盟和邀请小店加盟的一次性奖励延迟发放时间</span> -->
        <!-- </div>
        
        <div class="col_setting">
          <span>服务商邀请小店入驻奖励:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="serviceForm.invitation_shop_rate"
           >
            <p class="note_back"
              slot="suffix">%</p>
          </el-input>

         <span style="margin-left:12px;">限全额返小店入驻数:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="serviceForm.invitation_shop_full_reward_num"
           >
            <p class="note_back"
              slot="suffix">个</p>
          </el-input>
          <span class="note_span">入驻费分润规则设置</span>
        </div>
         <div class="col_setting">
          <span>:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="serviceForm.recharge_red_packet_rate"
           >
            <p class="note_back"
              slot="suffix">%</p>
          </el-input>
          <span class="note_span">按实付金额的固定百分比分佣,计做服务商收益</span>
        </div>
        <div class="col_setting">
          <span>服务商邀请服务商成功奖励:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="serviceForm.invitation_sp_price"
           >
            <p class="note_back"
              slot="suffix">元</p>
          </el-input>
          <span class="note_span">邀请服务商成功后的一次性奖励金额设置</span>
        </div>
        <div class="col_setting">
          <span>服务商收取被邀请服务商服务费比例:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="serviceForm.service_price_rate"
            >
            <p class="note_back"
              slot="suffix">%</p>
          </el-input>
          <span class="note_span">邀请成功1名服务商后，被邀请服务商每月收入的固定百分比作为服务费奖励</span>
        </div>

        <div class="col_setting">
          <span>服务费计费项目设置:</span>
          <el-checkbox label="线上佣金收入"  v-model='serviceForm.is_compute_online_commission' style="margin-left:20px;"></el-checkbox>
          <el-checkbox label="小店加盟费" v-model="serviceForm.is_compute_invitation_shop"></el-checkbox>
          <el-checkbox label="下级服务商邀请奖励" v-model="serviceForm.is_compute_invitation_sp"></el-checkbox>
          <el-checkbox label="下级红包充值奖励" v-model="serviceForm.is_compute_recharge_red_packet"></el-checkbox>
        </div>
      </div>
    </div> -->

      <!--合伙人相关权限设置-->
    <!-- <div class="setting_mid">
      <p class="setting_title">合伙人相关权限设置</p>
      <el-button style="float:right;" size="mini" type="primary" @click="setPartnerlimitData">保存</el-button>
    </div> -->
    
       <!-- <div class="setting_bottom"> -->
      <!-- <div class="valite_setting"> -->
        <!-- <div class="col_setting">
          <span>服务商奖励收益延迟到账:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="partnerForm.reward_sp_delay"
           >
            <p class="note_back"
              slot="suffix">天</p>
          </el-input>
          <span style="margin-left:12px;">邀请小店奖励延迟到账:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="partnerForm.reward_shop_delay"
           >
            <p class="note_back"
              slot="suffix">天</p>
          </el-input> -->
          <!-- <span class="note_span">是指服务商邀请服务商加盟和邀请小店加盟的一次性奖励延迟发放时间</span> -->
        <!-- </div> -->
        
        <!-- <div class="col_setting"> -->
          <!-- <span>合伙人直邀小店入驻奖励:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="partnerForm.invitation_shop_rate"
           >
            <p class="note_back"
              slot="suffix">%</p>
          </el-input>
         
          <span style="margin-left:12px;">间接邀请收益:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="partnerForm.indirect_invitation_shop_rate"
           >
            <p class="note_back"
              slot="suffix">%</p>
          </el-input>
         <span style="margin-left:12px;">限全额返小店入驻数:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="partnerForm.invitation_shop_full_reward_num"
           >
            <p class="note_back"
              slot="suffix">个</p>
          </el-input> -->
          <!-- <span class="note_span">入驻费分润规则设置</span> -->
        <!-- </div> -->
         <!-- <div class="col_setting"> -->
          <!-- <span>直邀小店充值红包返利:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="partnerForm.recharge_red_packet_rate"
           >
            <p class="note_back"
              slot="suffix">%</p>
          </el-input>
          <span style="margin-left:12px;">间接充值收益:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="partnerForm.indirect_recharge_red_packet_rate"
           >
            <p class="note_back"
              slot="suffix">%</p>
          </el-input> -->
          <!-- <span class="note_span">按实付金额的固定百分比分佣,计做服务商收益</span> -->
        <!-- </div> -->
        <!-- <div class="col_setting">
          <span>合伙人邀请服务商成功奖励:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="partnerForm.invitation_sp_price"
           >
            <p class="note_back"
              slot="suffix">元</p>
          </el-input>
          <span style="margin-left:12px;">间接邀请收益:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="partnerForm.indirect_invitation_sp_price"
           >
            <p class="note_back"
              slot="suffix">元</p>
          </el-input>
          <span class="note_span">邀请服务商成功后的一次性奖励金额设置</span>
        </div>
        <div class="col_setting">
          <span>合伙人收取被邀请服务商服务费比例:</span>
          <el-input style="width:200px;"
            type="number"
            min="0"
            v-model="partnerForm.service_price_rate"
            >
            <p class="note_back"
              slot="suffix">%</p>
          </el-input>
          <span class="note_span">邀请成功1名服务商后，被邀请服务商每月收入的固定百分比作为服务费奖励</span>
        </div> -->

        <!-- <div class="col_setting">
          <span>计费项目设置:</span>
          <el-checkbox label="小店加盟费" v-model="partnerForm.is_compute_invitation_shop"></el-checkbox>
          <el-checkbox label="下级红包充值奖励" v-model="partnerForm.is_compute_recharge_red_packet"></el-checkbox>
        </div> -->
      <!-- </div> -->
    <!-- </div> -->
  </div>
</template>

<script>
import {
  settingShop,
  setShopLimit,
  setRebateRate,
  setWithdrawLimit,
  setWithdrawDescription,
  setRefundValidTerm,
  setTransactionRate,
  setVipImproveRate,
  setownorderInvalidtime,
  setSpServiceLimit,
  getSpServiceLimit,
  setSpServicePrice,
  setShopServicePrice,
  settingCommissionRate,
  settingTkCommissionRate,
  setWithDrawTaxDeductlimit,
  setPartnerlimit,
  getPartnerlimit,
  setDepositConfig,
  isShowDepositJoinShop,
  setShowDepositJoinShop
} from "@/api/setting";


export default {
  data () {
    return {
      order_return_days: "",
      rebate_rate: "",
      withdraw_limit: '',
      withdraw_description: '',
      refund_valid_term: '',//门店退款费率
      transaction_rate: '', //费率
      first_vip_improve_rebate:'',
      own_order_invalid_time:'',  //失效时间
      form: {
        explosive_limit: "", //爆品
        activity_limit: "", //活动
        product_limit: "", //商品库
        coupon_limit: "", //现金券数量限制
        vip_limit: "", //会员专享商品数限制
        preferential_coupon_limit: "" //满减优惠券限制
      },
      
      //服务商设置
      serviceForm:{
        reward_sp_delay:'',
        reward_shop_delay:'',
        invitation_shop_rate:'',
        invitation_shop_full_reward_num:'',
        recharge_red_packet_rate:'',
        invitation_sp_price:'',
        service_price_rate:'',
        is_compute_online_commission:false,
        is_compute_invitation_shop:false,
        is_compute_invitation_sp:false,
        is_compute_recharge_red_packet:false
      },
      //佣金比例设置
      rateForm:{
        shop:'',
        sp:'',
        partner:'',
        sp_service_price:'',
        tk_shop: '',
        tk_partner:'',
      },
      ruzhuForm: {
        shop_service_price:'',
      },
      //服务商提现代扣税设置
      tax_point:'',
      freeze_expire_day:'',

      //合伙人相关权限设置
      partnerForm:{
        reward_sp_delay:'',
        reward_shop_delay:'',
        invitation_shop_rate:'',
        indirect_invitation_shop_rate:'',
        invitation_shop_full_reward_num:'',
        recharge_red_packet_rate:'',
        indirect_recharge_red_packet_rate:'',
        invitation_sp_price:'',
        indirect_invitation_sp_price:'',
        service_price_rate:'',
        is_compute_online_commission:false,
        is_compute_invitation_shop:false,
        is_compute_invitation_sp:false,
        is_compute_recharge_red_packet:false
      },

      //入驻和退费相关
      depositform:{
        price:'',//押金缴费服务费金额
        user_vip_price_min:'',//小店最低会员费
        commission_rate_hui:'',//分成比例
        commission_rate_ptai:'',
        user_vip_commission_min:'',//押金入驻小店最低可分配会员费
        partner_reward_rate:'',
        partner_indirect_reward_rate:'',
        service_provider_reward_rate:''
      },
      //是否展示押金入驻
      is_show_deposit_join_shop:''
    };
  },
  mounted () {
    this.getsettingShopData();
    this.getSpServiceLimitData();
    this.getPartnerlimitData()
    this.getisShowDepositJoinShopData()
  },
  methods: {
    converseSettingInfo () {
      //保存设置

      this.$confirm("确定保存设置?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        // this.getsetOrderReturnDaysData();
        
        if(this.refund_valid_term < 7 ){
          this.$message.error('有效期不能小于7天')
          return
        }
        if(this.transaction_rate > 1 ){
          this.$message.error('费率不能大于1')
          return
        }

        // if(Number(this.first_vip_improve_rebate) == 0){
        //   this.$message.error('完善信息返还红包金额不能为0')
        //   return
        // }

        if(Number(this.own_order_invalid_time) < 0){
          this.$message.error('失效时间不能少于0分钟')
          return
        }
        this.getsetShopLimitData();
        this.setRebateRateData();
        this.setWithdrawLimitData();
        this.setWithdrawDescriptionData()
        this.setRefundValidTermData()
        this.setTransactionRateData()
        this.setVipImproveRateData()
        this.setownorderInvalidtimeData()
      });
    },

    //获取小店设置
    async getsettingShopData () {
      let res = await settingShop();
      console.log(res)
      if (res.code === 10000) {
        this.refund_valid_term = res.data.refund_valid_term,//门店退款费率
          this.transaction_rate = res.data.transaction_rate, //费率
          // this.order_return_days = res.data.order_return_days;
          this.rebate_rate = res.data.rebate_rate;
        this.withdraw_limit = res.data.withdraw_limit;
        this.first_vip_improve_rebate = res.data.first_vip_improve_rebate/100
        this.withdraw_description = res.data.withdraw_description
        this.form = res.data.shop_limit;
        this.own_order_invalid_time   = res.data.own_order_invalid_time
        this.ruzhuForm.shop_service_price = res.data.shop_service_price
        this.rateForm.sp_service_price = res.data.sp_service_price
        this.rateForm.shop = res.data.commission_rate.shop
        this.rateForm.sp = res.data.commission_rate.sp
        this.rateForm.partner = res.data.commission_rate.partner
        this.rateForm.tk_shop = res.data.tk_commission_rate.tk_shop
        this.rateForm.tk_partner = res.data.tk_commission_rate.tk_partner
        this.tax_point = res.data.withdraw_tax_deduct_limit.tax_point
        this.freeze_expire_day = res.data.withdraw_tax_deduct_limit.freeze_expire_day
        this.depositform.price = res.data.shop_service_deposit_config.price
        this.depositform.user_vip_price_min = res.data.shop_service_deposit_config.user_vip_price_min
        this.depositform.user_vip_commission_min = res.data.shop_service_deposit_config.user_vip_commission_min
        this.depositform.partner_reward_rate = res.data.shop_service_deposit_config.partner_reward_rate
        this.depositform.partner_indirect_reward_rate = res.data.shop_service_deposit_config.partner_indirect_reward_rate
        this.depositform.service_provider_reward_rate = res.data.shop_service_deposit_config.service_provider_reward_rate

        if(res.data.shop_service_deposit_config.commission_rate.indexOf(':')>-1){
          var arr = res.data.shop_service_deposit_config.commission_rate.split(':')
          this.depositform.commission_rate_hui = arr[0]
          this.depositform.commission_rate_ptai = arr[1]
        }
      } else
        this.$message.error(res.message);
    },


    //设置过期时间
    // async getsetOrderReturnDaysData() {
    //   let res = await setOrderReturnDays({
    //     order_return_days: this.order_return_days
    //   });
    //   console.log(res);
    // },
    async getsetShopLimitData () {
      let res = await setShopLimit(this.form);
      if (res.code === 10000) {
        this.$message.success("设置小店权限成功");
      } else {
        this.$message.error(res.message);
      }
    },
    async setRebateRateData () {
      let res = await setRebateRate({ rebate_rate: this.rebate_rate })
      if (res.code === 10000) {
        console.log(res.message)
      } else {
        this.$message.error(res.message);
      }
    },

    async setWithdrawLimitData () {
      let res = await setWithdrawLimit({ withdraw_limit: this.withdraw_limit })

      if (res.code === 10000) {
        console.log(res.message)
      } else {
        this.$message.error(res.message);
      }
    },
    async setWithdrawDescriptionData () {
      let res = await setWithdrawDescription({ withdraw_description: this.withdraw_description })
      if (res.code === 10000) {
        console.log(res.message)
      } else {
        this.$message.error(res.message);
      }
    },
    async  setRefundValidTermData(){
       let res = await setRefundValidTerm({refund_valid_term:this.refund_valid_term})
       console.log(res)
    },
    async setTransactionRateData(){
      let res = await setTransactionRate({transaction_rate:this.transaction_rate})
       console.log(res)
    },
    async setVipImproveRateData(){
      let res  = await setVipImproveRate({first_vip_improve_rebate:this.first_vip_improve_rebate})
      console.log(res)
    },

    async  setownorderInvalidtimeData(){
       let res  = await  setownorderInvalidtime(
         {own_order_invalid_time:this.own_order_invalid_time})
       console.log(res)
    },
    //设定服务商权限
    async setSpServiceLimitData(){
      
       var partform = {
          //sp_limit
        // 'sp_limit[community_count]':this.serviceForm.community_count,
        'sp_limit[reward_sp_delay]':this.serviceForm.reward_sp_delay,
        'sp_limit[reward_shop_delay]':this.serviceForm.reward_shop_delay,
        'sp_limit[invitation_shop_rate]':this.serviceForm.invitation_shop_rate,
        'sp_limit[invitation_shop_full_reward_num]':this.serviceForm.invitation_shop_full_reward_num,
        'sp_limit[recharge_red_packet_rate]':this.serviceForm.recharge_red_packet_rate,
        'sp_limit[invitation_sp_price]':this.serviceForm.invitation_sp_price,
        'sp_limit[service_price_rate]':this.serviceForm.service_price_rate,
        'sp_limit[is_compute_online_commission]':Number(this.serviceForm.is_compute_online_commission),
        'sp_limit[is_compute_invitation_shop]':Number(this.serviceForm.is_compute_invitation_shop),
        'sp_limit[is_compute_invitation_sp]':Number(this.serviceForm.is_compute_invitation_sp),
        'sp_limit[is_compute_recharge_red_packet]':Number(this.serviceForm.is_compute_recharge_red_packet)
       }
      
      let res  = await  setSpServiceLimit(partform)
      if(res.code === 10000){
        this.$message.success(res.message)
      }else{
        this.$message.error(res.message)
      }
    },
    //获取服务商权限相关配置
    async getSpServiceLimitData(){
      let res = await  getSpServiceLimit()
      if(res.code === 10000){
        this.serviceForm = res.data
        

       
        if(this.serviceForm.is_compute_online_commission){
           this.serviceForm.is_compute_online_commission = Boolean(this.serviceForm.is_compute_online_commission =='1')
        }
       
        if(this.serviceForm.is_compute_invitation_shop){
          this.serviceForm.is_compute_invitation_shop = Boolean(this.serviceForm.is_compute_invitation_shop=='1')
        }
        if(this.serviceForm.is_compute_invitation_sp){
          this.serviceForm.is_compute_invitation_sp = Boolean(this.serviceForm.is_compute_invitation_sp=='1')
        }
        if(this.serviceForm.is_compute_recharge_red_packet){
          this.serviceForm.is_compute_recharge_red_packet = Boolean(this.serviceForm.is_compute_recharge_red_packet=='1')
        }

      }else{
        this.$message.error(res.error)
      }
    },
    //上传服务商相关配置信息
    converseServiceIsp(){
      //
      this.setSpServiceLimitData()
    },
    //保存佣金比例设置
    converseServiceCommissionRate(){
        this.getsettingCommissionRateData()
        // this.getsetSpServicePrice()
        // this.getsetShopServicePrice()
    },
    converseTkServiceCommissionRate(){
        this.getsettingTkCommissionRateData()
        // this.getsetSpServicePrice()
        // this.getsetShopServicePrice()
    },
    //佣金比例
    async getsettingCommissionRateData(){
      let res = await settingCommissionRate({
        "commission_rate[shop]":this.rateForm.shop,
        // "commission_rate[sp]":this.rateForm.sp,
        "commission_rate[partner]":this.rateForm.partner
      })
      if(res.code === 10000){
         console.log(res)
      }else{
        this.$message.error(res.message)
      }
    },
    async getsettingTkCommissionRateData(){
      let res = await settingTkCommissionRate({
        "tk_commission_rate[tk_shop]":this.rateForm.tk_shop,
        // "commission_rate[sp]":this.rateForm.sp,
        "tk_commission_rate[tk_partner]":this.rateForm.tk_partner
      })
      if(res.code === 10000){
         console.log(res)
      }else{
        this.$message.error(res.message)
      }
    },

    //服务商服务费
    async getsetSpServicePrice(){
      let res = await setSpServicePrice({sp_service_price:this.rateForm.sp_service_price})
      if(res.code === 10000){
        console.log(res)
      }else{
        this.$message.error(res.message)
      }
    },
    //小店服务费
    async getsetShopServicePrice(){
       let res = await setShopServicePrice({shop_service_price:this.ruzhuForm.shop_service_price})
      if(res.code === 10000){
        this.$message.success(res.message)
      }else{
        this.$message.error(res.message)
      }
    },
    //服务商代扣税设置
    async setWithDrawTaxDeductlimitData(){
      if(!this.tax_point){
       this.$message.error('代扣税不能为空')
       return
      }
      if(!this.freeze_expire_day){
        this.$message.error('冻结可申请抵税有效期不能为空')
      }
      let  res = await setWithDrawTaxDeductlimit({
        'withdraw_tax_deduct_limit[tax_point]':this.tax_point,
        'withdraw_tax_deduct_limit[freeze_expire_day]':this.freeze_expire_day
      })
      if(res.code === 10000){
         this.$message.success('提现代扣税设置成功')
      }else{
        this.$message.error(res.message)
      }
    },
    //获取合伙人相关权限设置
    async getPartnerlimitData(){
      let res = await getPartnerlimit()
      if(res.code === 10000){
        this.partnerForm.reward_sp_delay =  res.data.reward_sp_delay,
        this.partnerForm.reward_shop_delay = res.data.reward_shop_delay,
        this.partnerForm.invitation_shop_rate = res.data.invitation_shop_rate,
        this.partnerForm.indirect_invitation_shop_rate = res.data.indirect_invitation_shop_rate,
        this.partnerForm.invitation_shop_full_reward_num = res.data.invitation_shop_full_reward_num,
        this.partnerForm.recharge_red_packet_rate = res.data.recharge_red_packet_rate,
        this.partnerForm.indirect_recharge_red_packet_rate =  res.data.indirect_recharge_red_packet_rate,
        this.partnerForm.invitation_sp_price = res.data.invitation_sp_price,
        this.partnerForm.indirect_invitation_sp_price = res.data.indirect_invitation_sp_price,
        this.partnerForm.service_price_rate = res.data.service_price_rate,
        this.partnerForm.is_compute_online_commission = res.data.is_compute_online_commission == 1 ? true:false,
        this.partnerForm.is_compute_invitation_shop =res.data.is_compute_invitation_shop  == 1 ? true:false,
        this.partnerForm.is_compute_invitation_sp=res.data.is_compute_invitation_sp  == 1 ? true:false,
        this.partnerForm.is_compute_recharge_red_packet = res.data.is_compute_recharge_red_packet  == 1 ? true:false
      }else{
        this.$message.error(res.message)
      }
    },
    //合伙人相关权限设置
    async setPartnerlimitData(){
      let res  = await setPartnerlimit({
        'partner_limit[reward_sp_delay]':this.partnerForm.reward_sp_delay,
        'partner_limit[reward_shop_delay]':this.partnerForm.reward_shop_delay,
        'partner_limit[invitation_shop_rate]':this.partnerForm.invitation_shop_rate,
        'partner_limit[indirect_invitation_shop_rate]':this.partnerForm.indirect_invitation_shop_rate,
        'partner_limit[invitation_shop_full_reward_num]':this.partnerForm.invitation_shop_full_reward_num,
        'partner_limit[recharge_red_packet_rate]':this.partnerForm.recharge_red_packet_rate,
        'partner_limit[indirect_recharge_red_packet_rate]':this.partnerForm.indirect_recharge_red_packet_rate,
        'partner_limit[invitation_sp_price]':this.partnerForm.invitation_sp_price,
        'partner_limit[indirect_invitation_sp_price]':this.partnerForm.indirect_invitation_sp_price,
        'partner_limit[service_price_rate]':this.partnerForm.service_price_rate,
        'partner_limit[is_compute_online_commission]':Number(this.partnerForm.is_compute_online_commission),
        'partner_limit[is_compute_invitation_shop]':Number(this.partnerForm.is_compute_invitation_shop),
        'partner_limit[is_compute_invitation_sp]':Number(this.partnerForm.is_compute_invitation_sp),
        'partner_limit[is_compute_recharge_red_packet]':Number(this.partnerForm.is_compute_recharge_red_packet)
      })
      
      if(res.code === 10000){
        this.$message.success('合伙人相关权限设置成功')
      }else {
        this.$message.error(res.message)
      }
    },

    //保存小店和入驻费相关
    converseDepositConfig(){
       if(Number(this.depositform.price) <= 0){
         this.$message.error('押金入驻飞不能小于0或者为空')
         return
       }

         if(Number(this.depositform.commission_rate_hui) <= 0 || Number(this.depositform.commission_rate_ptai)  <= 0){
         this.$message.error('会员费分成设置不能为空或者小于0')
         return
       }
        if(Number(this.depositform.user_vip_price_min) <= 0){
         this.$message.error('押金入驻小店最低会员费不能小于0或者为空')
         return
       }
        if(Number(this.depositform.user_vip_commission_min) <= 0){
         this.$message.error('押金入驻小店最低可分配会员费不能小于0或者为空')
         return
       }
       if(Number(this.depositform.partner_reward_rate) <= 0){
         this.$message.error('合伙人直邀比例不能小于0或者为空')
         return
       }
       if(Number(this.depositform.partner_indirect_reward_rate) <= 0){
         this.$message.error('合伙人间接邀请比例不能小于0或者为空')
         return
       }
       if(Number(this.depositform.service_provider_reward_rate) <= 0){
         this.$message.error('服务商直邀比例不能小于0或者为空')
         return
       }
      this.setDepositConfigData()
      this.setShowDepositJoinShopData()
    },
    async setDepositConfigData(){
       var form = {
         price:this.depositform.price,
         commission_rate:this.depositform.commission_rate_hui+':'+this.depositform.commission_rate_ptai,
         user_vip_price_min:this.depositform.user_vip_price_min,
         user_vip_commission_min:this.depositform.user_vip_commission_min,
         partner_reward_rate:this.depositform.partner_reward_rate,
         partner_indirect_reward_rate:this.depositform.partner_indirect_reward_rate,
         service_provider_reward_rate:this.depositform.service_provider_reward_rate
       }
       let res = await setDepositConfig(form)
       if(res.code === 10000){
         this.$message.success(res.message)
       }else{
         this.$message.error(res.message)
       }
    },

    //获取是否展示
    async getisShowDepositJoinShopData(){
      let res = await isShowDepositJoinShop()
      this.is_show_deposit_join_shop = res.data.is_show_deposit_join_shop
    },

    //设置是否展示押金入驻
    async setShowDepositJoinShopData(){
      let res = await setShowDepositJoinShop({is_show_deposit_join_shop:this.is_show_deposit_join_shop})
      console.log(res)
    }

 
  }
};
</script>

<style lang="scss" scoped>
.shop {
  padding: 20px;
  position: relative;
  .valite_setting {
    background-color: #e8e8e8;
  }
  .setting_mid,
  .setting_member {
    margin-top: 30px;
  }
  .setting_bottom {
    background-color: #e8e8e8;
  }
  .setting_top {
    margin-top: 20px;
  }
  .valite_setting {
    padding: 10px;
  }
  .col_setting {
    margin: 10px 0;
  }
  .note_span {
    color: #fff;
    background-color: #f4442d;
    margin-left: 10px;
  }
  .setting_converse {
    position: absolute;
    top: 10px;
    right: 20px;
  }
  .note_back {
    margin-top: 10px;
  }
  .setting_title {
    font-weight: 700;
    font-size: 18px;
  }
  .rate_span{
    color: #fff;
    background-color: #f4442d;
    margin: 10px 0;
  }
}
</style>